<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>
        <?php echo siteInfo('sitename');?>
    </title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="<?php echo U_RES;?>/lib/layui/css/layui.css">
    <link rel="stylesheet" href="<?php echo U_RES_APP;?>/css/login.css">    
    <!--[if lt IE 9]>
          <script src="<?php echo U_RES;?>/lib/js/html5shiv-printshiv.min.js"></script>
          <script src="<?php echo U_RES;?>/lib/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="main-body">
        <div class="login-main">
            <div class="login-top">
                <span>
                    <?php echo siteInfo('sitename');?>
                </span>
                <span class="bg1"></span>
                <span class="bg2"></span>
            </div>
            <form class="layui-form login-bottom">
                <div class="center">
                    <div class="item">
                        <span class="icon icon-2"></span>
                        <input type="text" name="username" lay-verify="required" placeholder="请输入登录账号" maxlength="24" />
                    </div>
                    <div class="item">
                        <span class="icon icon-3"></span>
                        <input type="password" name="password" lay-verify="required" placeholder="请输入密码" maxlength="20">
                    </div>
                    <div id="validatePanel" class="item" style="width: 137px;">
                        <input type="text" id="captcha" name="captcha" placeholder="请输入验证码" maxlength="4" value="">
                        <img id="refreshCaptcha" class="validateImg"  src="">
                    </div>
                </div>
                <div class="tip">
                    <input type="checkbox" name="keeplogin" title="保持登录" checked>
                </div>
                <div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
                    <button class="login-btn" lay-submit="" lay-filter="login">立即登录</button>
                </div>
            </form>
        </div>
    </div>
    <script src="<?php echo U_RES;?>/lib/jquery-1.11.3.min.js"></script>
    <script src="<?php echo U_RES;?>/lib/layui/layui.js" charset="utf-8"></script>
    <script>
        layui.define(function () {
            var form = layui.form,layer = layui.layer,$ = layui.jquery;
            var codeSrc = './admin?c=login&a=verify';
            $('#refreshCaptcha').attr("src",codeSrc);
            form.on('submit(login)', function (data) {
                data = data.field;
                if (data.username == '') {
                    layer.msg('用户名不能为空');
                    return false;
                }
                if (data.password == '') {
                    layer.msg('密码不能为空');
                    return false;
                }
                if (data.captcha == '') {
                    layer.msg('验证码不能为空');
                    return false;
                }
                loading = layer.load(1, { shade: [0.1, '#fff'] });
                $.post('<{CAUrl("login","login")}>', data, function (res) {
                    layer.close(loading);
                    if (res.status == 1) {
                        layer.msg(res.info, { icon: 1, time: 1000 }, function () {
                            location.href = './admin';
                        });
                    } else {
                        $('#captcha').val('');
                        $('#refreshCaptcha').attr("src",codeSrc);
                        layer.msg(res.info, { icon: 2, anim: 6, time: 5000 });
                        //$('.captcha img').attr('src', '<{CAUrl("login","verify")}>' + Math.random());                       
                    }
                });
                return false;
            });
            //重置验证码
            $('#refreshCaptcha').click(function(){
                this.src = codeSrc;
            });
        });
    </script>
</body>
</html>